home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Windows Expert
/
Windows Expert.iso
/
network
/
atre12.zip
/
MOSQUITO.ZIP
/
MOSQWIN.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-07-05
|
9KB
|
217 lines
/*****************************************************************************
**** ****
**** mosqwin.c ****
**** ****
**** Copyright (C) A. Dwelly and W.W. Armstrong, 1990. ****
**** ****
**** All rights reserved. ****
**** ****
**** Attachment of copyright does not imply publication. ****
**** This file contains information which is proprietary ****
**** to the authors. ****
**** ****
**** This is a test of the research version of the adaptive logic ****
**** network package atree. This particular program demonstrates the ****
**** algorithm's ability to extract a simple relationship from complex ****
**** data. ****
**** ****
**** Each entry in the training set represents a human about which ****
**** 80 facts are known, represented by randomly setting bits. The ****
**** function _mosquito()_ is a single bit which is set if the patient ****
**** has been bitten by a mosquito (bit 1) is not taking quinine (bit 7) ****
**** and does not have sickle cell anemia (bit 12). The programer is free****
**** to increase the difficulty of the experiment by modifying the ****
**** initial constants. ****
**** ****
**** As the program is set up, the algorithm is searching in a space ****
**** of 2^80 bits, that is, 1208925819614629174706176 seperate bit ****
**** patterns, from this, it sees a mere 500 (a fraction of 1% of the ****
**** possible patterns) but correctly deduces the relationship between ****
**** the known facts, and the health of the patients. ****
**** ****
**** The adaptive logic network package based on work done by Prof. W. ****
**** W. Armstrong and others in the Department of Computing Science, ****
**** University of Alberta, and previous work at the Universite de ****
**** Montreal, and at AT&T Bell Laboratories, Holmdel, N. J. The ****
**** software demonstrates that networks consisting of many layers of ****
**** linear threshold elements can indeed be effectively trained. ****
**** ****
**** License: ****
**** A royalty-free license is granted for the use of this software for ****
**** NON_COMMERCIAL PURPOSES ONLY. The software may be copied and ****
**** modified provided this notice appears in its entirety and unchanged ****
**** in all copies, whether changed or not. Persons modifying the code ****
**** are requested to state the date, the changes made and who made them ****
**** in the modification history. ****
**** ****
**** Warranty: ****
**** No warranty of any kind is provided with this software. ****
**** This software is not supported. Neither the authors, nor the ****
**** University of Alberta, its officers, agents, servants or employees ****
**** shall be liable or responsible in any way for any damage to ****
**** property or direct personal or consequential injury of any nature ****
**** whatsoever that may be suffered or sustained by any licensee, user ****
**** or any other party as a consequence of the use or disposition of ****
**** this software. ****
**** ****
**** Patent: ****
**** The use of a digital circuit which transmits a signal indicating ****
**** heuristic responsibility is protected by U. S. Patent 3,934,231 ****
**** and others assigned to Dendronic Decisions Limited of Edmonton, ****
**** W. W. Armstrong, President. ****
**** ****
**** Modification history: ****
**** ****
**** 20.5.91 Initial Implementation, M. Thomas ****
**** ****
*****************************************************************************/
/*****************************
* Windows Support File for
* MOSQUITO.C
******************************/
#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
#include "atree.h"
#include "mosqwin.h"
#include "mosqdlg.h"
extern NEAR PASCAL main(HWND);
long FAR PASCAL WndProc (HWND, WORD, WORD, LONG);
BOOL FAR PASCAL AboutDlgProc (HWND, WORD, WORD, LONG);
HANDLE hInst;
FARPROC lpitAbout;
#pragma argsused
int PASCAL WinMain(HANDLE hInstance, HANDLE hPrevInstance,
LPSTR lpszCmdLine, int nCmdShow)
{
static char szAppName[] = "MOSQUITO";
HWND hwnd;
MSG msg;
WNDCLASS wndclass;
if (!hPrevInstance)
{
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon(hInstance, "mosqico");
wndclass.hCursor = LoadCursor(hInstance, "mosqcur");
wndclass.hbrBackground = GetStockObject(WHITE_BRUSH);
wndclass.lpszMenuName = "MENU_RESOURCE";
wndclass.lpszClassName = szAppName;
RegisterClass(&wndclass);
}
hInst = hInstance;
hwnd = CreateWindow(szAppName, /* Class */
"Mosquito", /* Title */
WS_OVERLAPPEDWINDOW, /* Style */
CW_USEDEFAULT, CW_USEDEFAULT, /* x, y */
240,180, /* xsize, ysize */
NULL, /* parent */
NULL, /* class menu */
hInstance, /* creator */
NULL); /* Params */
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
lpitAbout = MakeProcInstance((FARPROC)AboutDlgProc, hInst);
while (GetMessage(&msg, NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
long FAR PASCAL WndProc (HWND hwnd, WORD message, WORD wParam, LONG lParam)
{
HANDLE hMenu, hSysMenu;
static int cRun = 0;
switch (message)
{
case WM_COMMAND:
hMenu = GetMenu(hwnd);
hSysMenu = GetSystemMenu(hwnd, 0);
switch (wParam)
{
case IDM_EXIT:
DestroyWindow(hwnd);
break;
case IDM_RUN:
EnableMenuItem(hMenu, IDM_EXIT, MF_GRAYED);
EnableMenuItem(hSysMenu, SC_CLOSE, MF_GRAYED);
DrawMenuBar(hwnd);
cRun ++;
if (!main(hwnd))
{
cRun --;
MessageBeep(0);
MessageBox(hwnd,"Mosquito could not infect!", "Mosquito", MB_OK);
}
cRun --;
EnableMenuItem(hMenu, IDM_RUN, MF_ENABLED);
if (!cRun)
{
EnableMenuItem(hMenu, IDM_EXIT, MF_ENABLED);
EnableMenuItem(hSysMenu, SC_CLOSE, MF_ENABLED);
}
DrawMenuBar(hwnd);
break;
case IDM_ABOUT:
DialogBox(hInst,
MAKEINTRESOURCE(IDD_ABOUT),
hwnd,
lpitAbout);
break;
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,message,wParam,lParam);
}
return 0L;
}
#pragma argsused
BOOL FAR PASCAL AboutDlgProc (HWND hdlg, WORD message, WORD wParam, LONG lParam)
{
switch (message)
{
case WM_COMMAND:
EndDialog(hdlg, TRUE);
return TRUE;
default:
return FALSE;
}
}